<template>
  <div class="full-box shadow-box padding-box">
    <OperateCollection :showAdd="false" @search="initData">
      <template #condition>
        <div class="condition-item">
          <el-input
            v-model="queryParams.project_name"
            placeholder="按项目名称关键字查询"
            clearable
          ></el-input>
        </div>
        <div class="condition-item">
          <el-select
            style="width: 150px"
            v-model="queryParams.status"
            value-key=""
            placeholder="按状态查询"
            clearable
            filterable
          >
            <el-option :key="0" label="全部" value=""></el-option>
            <el-option :key="1" label="待审核" :value="10"></el-option>
            <el-option :key="2" label="退回" :value="15"></el-option>
            <el-option :key="3" label="通过" :value="20"></el-option>
          </el-select>
        </div>
      </template>
    </OperateCollection>
    <div class="table-wrapper">
      <BaseTable
        :columns="columns"
        :showSort="true"
        :tableData="tableData"
        :pages="{
          show: true,
          count: count,
        }"
        :operate="{
          show: true,
          width: 150,
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button
            type="primary"
            size="mini"
            @click="linkToDetails(current.row)"
            >详情</el-button
          >
        </template>
      </BaseTable>
    </div>
  </div>
</template>

<script>
import BaseTable from "@/components/Common/BaseTable.vue";
import OperateCollection from "./components/OperateCollection.vue";
import { getPerformanceSelfAssessmentList } from "@/api/WorkCollection/Index";
import commonList from "@/mixins/commonList";
export default {
  mixins: [commonList],
  components: { BaseTable, OperateCollection },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        pageType: 2,
        project_name: "",
        status: "", // 10待审核 15退回 20 通过 30已确认
      },
    };
  },
  methods: {
    initData() {
      getPerformanceSelfAssessmentList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
        }
      });
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    },
    linkToDetails(item) {
      localStorage.setItem("AssessmentDetail", JSON.stringify(item));
      this.$router.push(`/assessmentDetail/${item.id}/1`);
    },
  },
  created() {
    this.initData();
  },
};

const columns = [
  {
    prop: "project_name",
    label: "项目名称",
    width: "",
    minWidth: "300",
    align: "",
  },
  {
    prop: "owner_name",
    label: "建设单位",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "project_address",
    label: "建设地址",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "investment",
    label: "投资额 （万元）",
    width: "130",
    minWidth: "",
    align: "",
  },
  {
    prop: "fact_start_date",
    label: "开工日期",
    width: "130",
    minWidth: "",
    align: "",
  },
  {
    prop: "accept_date",
    label: "竣工日期",
    width: "130",
    minWidth: "",
    align: "",
  },
  {
    prop: "remark",
    label: "备注",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "status_text",
    label: "状态",
    width: "100",
    minWidth: "",
    align: "",
  },
];
</script>

<style lang="scss" scoped="">
</style>